double waypt_time(const Waypoint* wpt);
double waypt_speed(const Waypoint* A, const Waypoint* B);
double waypt_speed_ex(const Waypoint* A, const Waypoint* B);
+double waypt_vertical_speed(const Waypoint* A, const Waypoint* B);
double waypt_course(const Waypoint* A, const Waypoint* B);
double waypt_distance(const Waypoint* A, const Waypoint* B);
double waypt_distance_ex(const Waypoint* A, const Waypoint* B);
static int stnum;
static gbfile* fout;
static const Waypoint* prevwpp;
+static double vspeed;
/* internal helper functions */
else
gbfprintf(fout, " -");
break;
+ case 'v':
+ gbfprintf(fout, "%2.2f", vspeed);
+ break;
case 't':
{
QTime t = prevwpp->GetCreationTime().toUTC().time();
* associated waypoint plus that of the following one.
* Since we get waypoints one at a time, the only way is to store one and
* defer processing until we get the next one.
+ *
+ * To determine vertical speed we need to have not only previous waypoint,
+ * but also pre-previous, so we calculate vspeed right before forgetting
+ * the previous.
*/
if ((stnum == 1) && (time_offset == 0))
/*
if (prevwpp) {
subrip_prevwp_pr(waypointp);
+ vspeed = waypt_vertical_speed(waypointp, prevwpp);
}
prevwpp = waypointp;
}
time_offset = 0;
prevwpp = NULL;
+ vspeed = 0;
if ((opt_gpstime != NULL) && (opt_gpsdate != NULL)) {
time(&gpstime_t);
}
}
+/*
+ * Calculates the vertical speed between points "A" and "B"
+ * the result comes in meters per second and can be negative.
+ */
+
+double
+waypt_vertical_speed(const Waypoint* A, const Waypoint* B)
+{
+ double altitude, time;
+
+ altitude = A->altitude - B->altitude;
+ if (altitude == 0) {
+ return 0;
+ }
+
+ time = fabs((double)A->creation_time.msecsTo(B->creation_time)) / 1000.0;
+ if (time > 0) {
+ return (altitude / time);
+ } else {
+ return 0;
+ }
+}
+
/*
* Calculates "Course True" from A to B
*/
<entry>%e</entry>
<entry>elevation in meters</entry>
</row>
+<row>
+ <entry>%v</entry>
+ <entry>vertical speed in m/s</entry>
+</row>
<row>
<entry>%t</entry>
- <entry>tiomestamp</entry>
+ <entry>timestamp</entry>
</row>
<row>
<entry>%l</entry>